<template>
  <div>
    <el-row>
      <el-col :span="24">
        <div class="addccc">
          <el-button
            @click="addition(1)"
            type="primary"
            icon="el-icon-circle-plus-outline"
            >新建记录</el-button
          >
          <el-radio-group
            v-model="tabPosition"
            size="small"
            style="margin-left: 30px"
          >
            <el-radio-button label="待我处理"></el-radio-button>
            <el-radio-button label="待认领"></el-radio-button>
            <el-radio-button label="我的反馈"></el-radio-button>
            <el-radio-button label="所有"></el-radio-button>
          </el-radio-group>
          <el-select
            v-model="product"
            placeholder="请选择产品"
            style="margin-left: 30px"
          >
            <el-option
              v-for="item in typeList"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
          <el-input
            size="medium"
            v-model="mLast"
            placeholder="查询"
            style="margin-left: 30px; width: 250px"
          ></el-input>
          <div>推送到首页、处理</div>
        </div>
      </el-col>
      <el-col :span="24">
        <div>
          <el-table :data="tableData" style="width: 100%">
            <el-table-column type="expand">
              <template #default="props">
                <el-form label-position="left" inline class="demo-table-expand">
                  <el-form-item label="处理时间:">
                    <span>{{ props.row.repairTimeStr }}</span>
                  </el-form-item>
                  <el-form-item label="问题详情:">
                    <span>{{ props.row.problemDetail }}</span>
                  </el-form-item>
                  <el-form-item label="资料:">
                    <span>{{ props.row.files }}</span>
                  </el-form-item>
                  <el-form-item label="处理详情:">
                    <span>{{ props.row.repairDetail }}</span>
                  </el-form-item>
                </el-form>
              </template>
            </el-table-column>
            <el-table-column label="产品" prop="product"> </el-table-column>
            <el-table-column label="问题摘要" prop="summary">
              <template #default="scope">
                <el-tag
                  v-if="scope.row.isDone"
                  size="small"
                  effect="light"
                  type="primary"
                  >已结单</el-tag
                >
                <el-tag v-else size="small" effect="dark" type="danger"
                  >待处理</el-tag
                >
                <span style="margin-left: 10px">{{ scope.row.summary }} </span>
              </template>
            </el-table-column>
            <el-table-column label="出现时间" prop="appearTimeStr">
            </el-table-column>
            <el-table-column label="反馈人员" prop="name"> </el-table-column>
            <el-table-column label="调试人员" prop="name"> </el-table-column>
            <el-table-column label="操作" width="320" align="center">
              <template #default="scope">
                <el-button
                  size="mini"
                  type="warning"
                  @click="arraycopy(scope.row)"
                  >认领</el-button
                >
                <el-button size="mini" type="danger">删除</el-button>
              </template>
            </el-table-column>
          </el-table>
        </div>
      </el-col>
    </el-row>
    <el-dialog
      :title="single"
      v-model="plassets"
      width="30%"
      :close-on-click-modal="false"
    >
      <el-form ref="form" :model="form" label-width="100px">
        <el-form-item label="产品">
          <el-input v-model="form.product" style="width: 300px"></el-input>
        </el-form-item>
        <el-form-item label="问题摘要">
          <el-input v-model="form.problem" style="width: 300px"></el-input>
        </el-form-item>
        <el-form-item label="详情描述">
          <el-input
            type="textarea"
            :rows="2"
            style="width: 300px"
            placeholder="请输入内容"
            v-model="form.details"
          >
          </el-input>
        </el-form-item>
        <el-form-item label="出现时间">
          <el-date-picker
            style="width: 300px"
            v-model="form.dates"
            type="date"
            placeholder="选择日期"
            format="YYYY 年 MM 月 DD 日"
          >
            >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="维修/调试人员"> </el-form-item>
        <el-form-item label="资料上传">
          <el-upload
            class="upload-demo"
            action="https://jsonplaceholder.typicode.com/posts/"
            :on-preview="handlePreview"
            :on-remove="handleRemove"
            :before-remove="beforeRemove"
            multiple
            :limit="3"
            :on-exceed="handleExceed"
            :file-list="fileList"
          >
            <el-button size="small" type="primary">点击上传</el-button>
            <template #tip>
              <div class="el-upload__tip">
                只能上传 jpg/png 文件，且不超过 500kb
              </div>
            </template>
          </el-upload>
        </el-form-item>
      </el-form>
    </el-dialog>
  </div>
</template>

<script>
export default {
  data() {
    return {
      form: {
        product: "",
        problem: "",
        details: "",
        dates: "",
      },
      plassets: false,
      single: "",
      under: 1,
      mLast: "", //查询
      product: "", //搜索产品
      fileList: [],
      typeList: [
        {
          value: "UYates在线",
          label: "UYates在线",
        },
        {
          value: "USGNet",
          label: "USGNet",
        },
        {
          value: "应力仪USG",
          label: "应力仪USG",
        },
        {
          value: "UTRT信号板卡",
          label: "UTRT信号板卡",
        },
        {
          value: "戬威后台",
          label: "戬威后台",
        },
      ],
      tabPosition: "待我处理",
      tableData: [
        {
          appearTime: "2021-03-18T00:00:00",
          createTime: "2021-03-19T15:55:18",
          id: 320,
          imgs: [],
          isDone: true,
          notify: false,
          problemDetail:
            "台湾仪器用的是老电源模块+研华主板。运行时极易自动关机",
          product: "应力仪USG",
          repairDetail: "更换新版电源模块之后，稳定。暂未出险自动关机的情况",
          repairTime: "2021-03-19T07:55:19",
          repairerId: [6],
          reporterId: 6,
          summary: "自动关机",
          updateTime: "2021-03-19T15:56:15",
        },
      ],
    };
  },
  methods: {
    addition(index) {
      this.plassets = true;
      this.under = index;
      this.single = "新增问题记录";
    },
    handleRemove(file, fileList) {
      console.log(file, fileList);
    },
    handlePreview(file) {
      console.log(file);
    },
    handleExceed(files, fileList) {
      this.$message.warning(
        `当前限制选择 3 个文件，本次选择了 ${files.length} 个文件，共选择了 ${
          files.length + fileList.length
        } 个文件`
      );
    },
    beforeRemove(file) {
      return this.$confirm(`确定移除 ${file.name}？`);
    },
  },
};
</script>

<style scoped>
.addccc {
  margin-bottom: 20px;
}
.demo-table-expand {
  font-size: 0;
}
.demo-table-expand label {
  width: 90px;
  color: #99a9bf;
}
.demo-table-expand .el-form-item {
  margin-right: 0;
  margin-bottom: 0;
  width: 100%;
}
</style>